package com.spring.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.spring.activity.QuerySZListActivity;
import com.spring.entity.Attendance;
import com.spring.gowhere.R;
import com.spring.util.DatetimeUtil;

import java.util.List;

/**
 * 项目名：智慧课牌
 * Created by ${LiuShaoQing} on 2017/9/13.
 * Time: 2017/9/13 15:07
 */

public class AKQInfoAdapter extends BaseAdapter {
    List<Attendance> mList;
    Context mCx;

    public AKQInfoAdapter(Context cx, List<Attendance> list) {
        this.mCx = cx;
        this.mList = list;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mCx).inflate(R.layout.akqin_info_dapter, null);
            holder.mSerialnumber = (TextView) convertView.findViewById(R.id.txSerialnumber);
            holder.mCardFixId = (TextView) convertView.findViewById(R.id.txFixNo);
            holder.ConsumeDate = (TextView) convertView.findViewById(R.id.txConsumeDate);
            holder.AreaName = (TextView) convertView.findViewById(R.id.txAreaName);
            holder.MealName = (TextView) convertView.findViewById(R.id.txMealName);
            holder.MealNumber = (TextView) convertView.findViewById(R.id.txMealNumber);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Attendance mAtt = mList.get(position);
        if (mAtt != null) {
            holder.mSerialnumber.setText(TextUtils.isEmpty(mAtt.BrushRecordId + "") ? "" : mAtt.BrushRecordId + "");
            holder.mCardFixId.setText(TextUtils.isEmpty(mAtt.CardID + "") ? "" : mAtt.CardID + "");
            holder.MealName.setText(TextUtils.isEmpty(mAtt.TermName) ? "" : mAtt.TermName);
            holder.MealNumber.setText(TextUtils.isEmpty(mAtt.DeviceId + "") ? "" : mAtt.DeviceId + "");
            holder.AreaName.setText(TextUtils.isEmpty(mAtt.AreaName) ? "" : mAtt.AreaName);
            holder.ConsumeDate.setText(TextUtils.isEmpty(mAtt.DateTimeBrush) ? "" : mAtt.DateTimeBrush);
        }


        return convertView;
    }

    public static class ViewHolder {
        public TextView mSerialnumber;
        public TextView mCardFixId;
        public TextView ConsumeDate;
        public TextView AreaName;// 所在区域
        public TextView MealName;
        public TextView MealNumber;

    }
}
